package com.x.erp.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.config.annotation.Reference;
import com.x.erp.model.CarImage;
import com.x.erp.rpc.CarImageRpcService;
import com.x.framework.controller.BaseController;
import com.x.framework.controller.ResultCode;
import com.x.framework.controller.ResultModel;

/**
 * 车辆图片服务
 */
@RestController
@RequestMapping("/carImage")
public class CarImageController extends BaseController {

	@Reference
	private CarImageRpcService carImageRpcService;// 车辆图片服务

	/**
	 * 车辆图片服务
	 * 
	 * @param
	 * @return
	 */
	@RequestMapping(value = "/getCarImageList", method = { RequestMethod.POST, RequestMethod.GET })
	public ResultModel getCarImageList(CarImage carImage, Integer imageViewId) {
		return new ResultModel(ResultCode.RESULT_SUCCESS, "查询成功",
				carImageRpcService.selectCarImageList(carImage, imageViewId));
	}

	/**
	 * 根据图片imageId删除图片
	 * 
	 * @param
	 * @return
	 */
	@RequestMapping(value = "/deleteCarImage", method = { RequestMethod.POST, RequestMethod.GET })
	public ResultModel deleteCarImage(CarImage carImage) {
		if (carImage == null) {
			return new ResultModel(ResultCode.RESULT_FAIL, "图片信息不能为空！");
		}
		return new ResultModel(ResultCode.RESULT_SUCCESS, "删除成功", carImageRpcService.deleteCarImage(carImage));
	}
}
